<?php

namespace slinks\extensions\container;

use slinks\core\DependencyInjection\ContainerBuilder;
use slinks\core\DependencyInjection\Loader\XmlFileLoader;
use slinks\core\Config\FileLocator;

/**
 * Description of XmlServiceFileVisitor
 *
 * @author navid
 */
class XmlServiceFileVisitor implements \slinks\common\io\IFileSystemVisitor {

    private $container;

    public function __construct(ContainerBuilder $container) {
        $this->container = $container;
    }

    /**
     * This is called for evey object accessed during the traversal of the fielsystem by the FileSystemReader.
     * @param SplFileInfo $info the SPLFileInfo object to represent the current portion of the file/directory tree.
     */
    public function visit(\SplFileInfo $info) {
        $loader = new XmlFileLoader($this->container, new FileLocator($info->getPath()));
        $loader->load($info->getFilename());
    }

}
